

// const Tortoise = require('tortoise');

const {rabbitmq} = require('./app/util/rabbitmq');

module.exports = app => {
    app.beforeStart(async () => {
        // 应用会等待这个函数执行完成才启动
        //app.baseDir = this.options.baseDir
        // Override timezone formatting for MSSQL
        const ctx = app.createAnonymousContext({});

        await rabbitmq.init(app,ctx);
        // const {tortoise} = app;
        // console.log(tortoise);
        // rabbitmq
        // https://github.com/CompassPHS/tortoise
        // 订阅
        // tortoise
        //     .queue('my-queue')
        //     .prefetch(1)
        //     // .json()
        //     .subscribe(function (msg, ack) {
        //         console.log(msg);
        //         ack();
        //     });

        // tortoise.on(Tortoise.EVENTS.PARSEERROR, function(err, msg) {
        //     // err is the error
        //     // msg is the message object returned from AMQP.
        //     // msg.content is the Buffer of the message
        //     console.log('An error occurred parsing the msg content');
        // });

    });
};